var profileApp = {
	_init : function() {
		// $('#submit_btn').on('click', profileApp._profile);
		$('form').on('keypress', profileApp._enterSubmit)
	},
	_profile : function(e) {
		if ($('#password_input').val() == '') {
			$('.form-action').before('<div class="control-group error"><label>密码错误!</label></div>');
			e.preventDefault();
			return false;
		}
	},
	
	_enterSubmit : function(e) {
		var theEvent = window.event || e;
		var code = theEvent.keyCode || theEvent.which;
		if (code == 13) {
			$("#submit_btn").submit();
		}
	}
};

$(function() {
	profileApp._init();
	Placeholders.init(true);
	$("#profile_form").validate({
		rules: {
			name: {
				required: true
			},
			tel: {
				required: true
			},
			birthYear : {
				required : true,
				minlength : 4,
				maxlength : 4,
				number : true
			},
			drivingAge : {
				required: true
			},
			drivingLicense : {
				required: true
			},
			county : {
				required: true
			}
		},
		messages : {
			name : {
				required : "请填写您的姓名。"
			},
			tel : {
				required : "请填写您的联系电话。"
			},
			birthYear : {
				required: "请填写您的出生年份。",
				minlength : "出生年份为4位数字",
				maxlength : "出生年份为4位数字",
				number : "出生年份为4位数字"
			},
			drivingAge : {
				required: "请选择您的驾龄。"
			},
			drivingLicense : {
				required: "请选择您的驾照级别。"
			},
			county : {
				required: "请选择您的服务区域。"
			}
		}
	});
});